<template>
	<view class="list flex-direction-column">
		<view class="item " v-for="item in props.list" :key="item.id" @click="itemClick(item.id)">
			<image class="pic" mode="aspectFill" :src="item.cover"></image>
			<view class="matchLogo">
				<image mode="aspectFill" :src="getImg(item,1)"></image>
				<view class="matchLogo_text" :style="getImg(item,2)">
					{{ getImg(item,3) }}
				</view>
			</view>
			<view class="title">
				<view>{{item.name}}</view>
				<view class="flex-space-between" style="margin-top: 20rpx;">
					<!-- 	<view class="time" v-if="item.status==9">
						报名截止：{{item.sign_end}}
					</view>
					<view class="time" v-if="item.status!=9">
						比赛时间：{{item.start_time}}
					</view> -->
					<view class="time">
						比赛时间：{{item.start_time}}
					</view>
					<view class="button" v-if="item.is_enroll!=0">已报名</view>
					<view v-if="item.is_enroll==0">
						<view class="button2" v-if="item.state==3">
							<view class="text">已暂停</view>
						</view>
						<view v-if="item.state==2">
							<view class="button">
								{{getImg(item,4)}}
							</view>
						</view>
						<view v-if="item.state!=2&&item.state!=3" class="button2">
							<view class="text">报名已截止</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
	import { PropType } from 'vue'
	import { Tlist } from '@/typings/list'
	import tools from '@/utils/tools'

	const props = defineProps({
		list: {
			type: Array as PropType<Tlist['item'][]>
		}
	})

	const itemClick = (id : number) => {
		tools.navTo('/pagesA/match/detail?id=' + id)
	}
	const getImg = (item : any, index : number) => {
		if (index == 1) {
			if (item.state == 3) return '/static/image/end.png'
			if (item.status == 9) return '/static/image/run.png'
			if (item.status == 7) return '/static/image/statr.png'
			return '/static/image/end.png'
		}
		if (index == 2) {
			if (item.state == 3) return 'background: rgba(203,206,212,1);'
			if (item.status == 9) return 'background: rgba(108,175,120,1)'
			if (item.status == 7) return 'background: rgba(253,118,131,1)'
			return 'background: rgba(203,206,212,1);'
		}
		if (index == 3) {
			if (item.state == 3) return '已暂停'
			if (item.status == 9) {
				if (item.day == 0) return '报名今天截止'
				return '距报名截止还有' + item.day + '天'
			}
			if (item.status == 8) return '报名未开始'
			if (item.status == 7) return '进行中'
			if (item.status == 6) return '报名结束'
			if (item.status == 5) return '已结束'

		}
		if (index == 4) {
			if (item.status == 9) return '报名中'
			if (item.status == 8) return '报名未开始'
			if (item.status == 7) return '进行中'
			if (item.status == 6) return '报名结束'
			if (item.status == 5) return '已结束'
		}
	}
</script>

<style lang="scss" scoped>
	.list {
		.item {
			flex: 1;
			border-radius: 10rpx;
			background-color: #fff;
			border-radius: 20rpx;
			margin-bottom: 20rpx;
			position: relative;

			.matchLogo {
				position: absolute;
				right: 0rpx;
				top: 250rpx;
				display: flex;

				image {
					width: 24rpx;
					height: 48rpx;
				}

				.matchLogo_text {
					height: 48rpx;
					font-size: 28rpx;
					color: #FFFFFF;
					text-align: left;
					padding: 5rpx 15rpx;
					background: rgba(253, 118, 131, 1);
				}
			}

			.pic {
				width: 100%;
				height: 332rpx;
				border-radius: 6rpx;

				border-radius: 20rpx 20rpx 0rpx 0rpx;
			}

			.title {
				text-align: left;
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: bold;
				padding: 16rpx 30rpx 10rpx 30rpx;

				.time {
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: 400;
					color: #999999;
					opacity: 1;
				}

				.button {
					text-align: center;
					padding: 10rpx 30rpx;
					background: linear-gradient(90deg, #F9AD3B 0%, #FD7683 100%);
					opacity: 1;
					border-radius: 32rpx;
					font-weight: 400;
					color: #FFFFFF;
					font-size: 32rpx;
				}

				.button2 {
					text-align: center;
					padding: 10rpx 30rpx;
					background: rgba(172, 172, 172, 0.4);
					border-radius: 32rpx;
					opacity: 1;
					font-size: 32rpx;
					font-weight: 400;

					.text {
						color: #FFFFFF;
						opacity: 1;
					}
				}
			}
		}
	}
</style>